package org.example.util;

import com.alibaba.excel.EasyExcel;

import java.util.ArrayList;
import java.util.List;

public class EasyExcelUtils {

    static private List<List<String>> gemComplexHead() {
        String companyName = "xxxx公司";
        String receivingUnit = "收货单位：xxx";
        String[] thirdLevelHeaders = {"年龄", "性别", "手机号", "国家", "省份"};
        List<List<String>> list = new ArrayList<>();
        for (String thirdLevelHeader : thirdLevelHeaders) {
            List<String> header = new ArrayList<>();
            header.add(companyName);
            header.add(receivingUnit);
            header.add(thirdLevelHeader);
            list.add(header);
        }
        return list;
    }



    public static void main(String[] args) {
        List<String> strings = new ArrayList<>();
        // 文件名
        String fileName = "example.xlsx";
        EasyExcel.write(fileName)
                //文件的表头
                .head(gemComplexHead())
                .sheet("模板")
                .doWrite(strings);
    }
}
